package com.jm.web.form.support;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;

import javax.servlet.jsp.JspWriter;

import org.htmlparser.Node;
import org.htmlparser.Parser;
import org.htmlparser.util.NodeIterator;
import org.xml.sax.InputSource;

import com.jm.utils.AttributeBuilder;
import com.jm.utils.StringHelper;
import com.jm.utils.Utils;
import com.jm.utils.htmlNode.NodeList;
import com.jm.utils.htmlNode.XmlNode;
import com.jm.web.BasePage;
import com.jm.web.data.BaseDataEntity;
import com.jm.web.form.Br;
import com.jm.web.form.Button;
import com.jm.web.form.Fieldset;
import com.jm.web.form.Group;
import com.jm.web.form.Input;
import com.jm.web.form.Option;
import com.jm.web.form.Script;
import com.jm.web.form.Select;
import com.jm.web.form.Separate;
import com.jm.web.form.Textarea;
import com.jm.web.form.table.Table;
import com.jm.web.form.table.Tbody;
import com.jm.web.form.table.Td;
import com.jm.web.form.table.Tfoot;
import com.jm.web.form.table.Th;
import com.jm.web.form.table.Thead;
import com.jm.web.form.table.Tr;
import com.jm.web.tags.support.BaseTag;
import com.jm.web.tags.support.DataSourceTag;

/**
 * @author yanjie
 *
 * 2011/9/19 上午11:28:03
 * 基本表单控件
 */
public class FormItem {
	protected Hashtable extAttrList = null;// new Hashtable();
	protected BaseTag baseTag = null ;
	protected int currentIndex = 0;//當前顯示到第幾個控件
	
	protected List<FormItem> items = null ;//所有子控件
	protected List<Script> script = null ;//所有子控件
	protected FormItem parentItem = null ;//父控件
	protected boolean enab = true;

	public static String TAG_ID = "id";
	public static String TAG_NODENAME = "NODENAME";
	public static String TAG_NODEVALUE = "NODEVALUE";
	public static String TAG_NAME = "name";
	public static String TAG_STYLE = "style";
	public static String TAG_CSS = "class";
	public static String TAG_WIDTH = "width";
	public static String TAG_HEIGHT = "height";
	public static String TAG_POS = "pos";//位置
	public static String TAG_INDEX = "0";//处理表单元素重复的时候,无法设置默认值的问题
	
	protected String strId = ""; // 节点ID
	protected String strNodeName = "";
	protected String strNodeValue = "";
	protected String strName = "";
	protected String strStyle = "";
	protected String strCss = "";
	protected String strWidth = "";
	protected String strHeight = "";
	protected int iPos = 0 ;
	protected int iIndex = 0 ;
	protected BaseDataEntity config = null;//导出配置
	
	public BaseDataEntity getConfig(String strParam){
		BaseDataEntity temConfig = null;
		String strConfig = this.GetExtValue(strParam,"");
		if(!StringHelper.IsNullOrEmpty(strConfig)){
			try {
				temConfig = BaseDataEntity.FromJSONString(StringHelper.Format("{%1$s}",strConfig));
			} catch (Exception e) {
				e.printStackTrace();
			}
			
		}
	
		if(temConfig == null) temConfig = new BaseDataEntity();
		return temConfig;
	}
	
	public BaseDataEntity getExportConfig(){
		if(config != null)
			return config;
		else{
			String strConfig = this.GetExtValue("exportconfig","");
			if(!StringHelper.IsNullOrEmpty(strConfig)){
				try {
					config = BaseDataEntity.FromJSONString(StringHelper.Format("{%1$s}",strConfig));
				} catch (Exception e) {
					e.printStackTrace();
				}
				
			}
		
			if(config == null) config = new BaseDataEntity();
		}
		return config;
	}
	
	protected boolean bFromTag = false ;//是否是tag生成的控件
	
	public void onRender(JspWriter writer){
		outItemBegin(writer);
		outItemBody(writer);
		outItemEnd(writer);
		
		//js
		if(this.getScript() != null && this.getScript().size()>0){
			//writer.write("<script>");
			for (int i = 0; i < this.getScript().size(); i++) {
				 try {
					writer.write(this.getScript().get(i).getNodeValue());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			//writer.write("</script>");
		}
	}
	
//	public String toOutString2(){
//		StringWriter writer = new StringWriter();
//		onRender(writer);
//		return writer.toString();
//	}
	
	public void init(){
		
	}
	
	public void outItemBegin(JspWriter writer){
		onOutItemBegin(writer);
	}
	
	/**
	 * 
	 */
	public void onOutItemBegin(JspWriter writer) {
		if(!StringHelper.IsNullOrEmpty(this.getNodeName())){
			try {
				writer.write(StringHelper.Format("<%1$s ",this.getNodeName()));
				AttributeBuilder attributesBuilder = new AttributeBuilder();
				attributesBuilder.InitFromHashtable(this.extAttrList,true);
				FillAttributeBuilder(attributesBuilder);
				writer.write(attributesBuilder.ToOutputString());
				writer.write(">");
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	public void outItemBodyHeader(JspWriter writer,FormItem item){
		
	}
	
	public void outItemBodyFooter(JspWriter writer,FormItem item){
		
	}
	
	public void outItemBody(JspWriter writer){
		if(this.getItems()  == null || this.getItems().size() == 0){
			currentIndex++;
			onOutItemBody(writer,this,true);
		}else{
			for (int i = 0 ;i<this.getItems().size();i++) {
				Object object = this.getItems().get(i);
				if (object instanceof FormItem) {
					FormItem item = (FormItem) object;
					currentIndex++;
					
					onOutItemBody(writer,item,false);
				}
			}
		}
	}
	
	public void onOutItemBody(JspWriter writer,FormItem item,boolean bRenderNodeValue){
		outItemBodyHeader(writer,item);
		if(bRenderNodeValue)
			onOutSingleBody(writer,item);
		else
			item.onRender(writer);
		outItemBodyFooter(writer,item);
	}
	
	public void onOutSingleBody(JspWriter writer,FormItem item){
		if(item.GetExtValue("bind",false) && !(item instanceof FieldItem)){
			if(this.getBaseTag() instanceof DataSourceTag){
				DataSourceTag dsTag = (DataSourceTag)this.getBaseTag();
				dsTag.FillFiledItemValue(item);
			}
		}
		try {
			writer.write(item.getNodeValue());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void outItemEnd(JspWriter writer){
		onOutItemEnd(writer);
	}
	
	public void onOutItemEnd(JspWriter writer){
		if(!StringHelper.IsNullOrEmpty(this.getNodeName())){
			try {
				writer.write(StringHelper.Format("</%1$s>",this.getNodeName()));
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	public void OnSetProperty(String strName, String strValue)
	{
		if (strName.compareToIgnoreCase(TAG_ID) == 0)
		{
			this.strId = strValue;
			return;
		}
		
		if (strName.compareToIgnoreCase(TAG_NODENAME) == 0)
		{
			this.strNodeName = strValue;
			return;
		}
		
		if (strName.compareToIgnoreCase(TAG_NODEVALUE) == 0)
		{
			this.strNodeValue = strValue;
			return;
		}
		
		
		if (strName.compareToIgnoreCase(TAG_NAME) == 0)
		{
			this.strName = strValue;
			//为了避免重复放入,如果是tag生成的控件则也不放入页面对像中 
			//filed 控件也不用放到页面对像中
			if(this.getBaseTag() != null){
				if(!StringHelper.IsNullOrEmpty(this.getName())
						&& !this.isFromTag() 
						&& !FieldItem.TAG_ITEMNAME.equalsIgnoreCase(this.getNodeName())
						){
					if(this.getBaseTag().getPage().hasDialog() && this.getBaseTag().isDialog()){
						this.getBaseTag().getPage().getDialog().addItem(this.getName(), this);
					}else{
						this.setIndex(this.getBaseTag().getPage().getItemSize(this.getName()));
						this.getBaseTag().getPage().addItem(this.getName(), this);
					}
				}else if(!StringHelper.IsNullOrEmpty(this.getName())
						&& this.isFromTag()){
					this.setIndex(this.getBaseTag().getPage().getTagItemSize(this.getName()));
					this.getBaseTag().getPage().addTagItem(this.getName(), this);
				}
			}
			return;
		}
		
		if (strName.compareToIgnoreCase(TAG_STYLE) == 0)
		{
			this.strStyle += strValue;
			return;
		}
		
		if (strName.compareToIgnoreCase(TAG_CSS) == 0)
		{
			this.strCss = strValue;
			return;
		}
		
		if (strName.compareToIgnoreCase(TAG_WIDTH) == 0)
		{
			this.strWidth = strValue;
			return;
		}
		
		if (strName.compareToIgnoreCase(TAG_HEIGHT) == 0)
		{
			this.strHeight = strValue;
			return;
		}
		
		if (strName.compareToIgnoreCase(TAG_POS) == 0)
		{
			this.iPos = StringHelper.GetValue(strValue,0);
			return;
		}

		// 不明属性
		if (extAttrList == null)
			extAttrList = new Hashtable();
		
		//_static 不转为大写 ,保持原大小写不变
		if(strName.endsWith("_static"))
			extAttrList.put(strName.replaceAll("_static",""), strValue);
		else
			extAttrList.put(strName.toUpperCase(), strValue);
		
	}
	
	public void OnSetProperty(String strName, Object object)
	{
		// 不明属性
		if (extAttrList == null)
			extAttrList = new Hashtable();
		
		//_static 不转为大写 ,保持原大小写不变
		if(strName.endsWith("_static"))
			extAttrList.put(strName.replaceAll("_static",""), object);
		else
			extAttrList.put(strName.toUpperCase(), object);
	}
	
	public void FillAttributeBuilder(AttributeBuilder attributesBuilder){
		if(!StringHelper.IsNullOrEmpty(this.getId()))
			attributesBuilder.Set(TAG_ID,this.getId());
		
		if(!StringHelper.IsNullOrEmpty(this.getName()))
			attributesBuilder.Set(TAG_NAME,this.getName());
		
		if(!StringHelper.IsNullOrEmpty(this.getStyle()))
			attributesBuilder.Append(TAG_STYLE,this.getStyle());
		
		if(!StringHelper.IsNullOrEmpty(this.getCss()))
			attributesBuilder.Append(TAG_CSS,this.getCss());
		
		if(Input.isInputText(this))
			attributesBuilder.Append(TAG_CSS,"ax-input-text");
		
		if(Select.isSelect(this))
			attributesBuilder.Append(TAG_CSS,"ax-select");
		
		if(!StringHelper.IsNullOrEmpty(this.getWidth())){
			if(!this.isFromTag())
			{
				String strWidth = this.getWidth().replace("px","");
				if(!StringHelper.IsNullOrEmpty(strWidth) && !strWidth.endsWith("%") && this instanceof Select){
					int iWidth = Integer.parseInt(strWidth);
					attributesBuilder.Append(TAG_STYLE,
							StringHelper.Format("width:%1$spx;_width:%2$spx;",iWidth+2,iWidth+2));
				}else{
					
					attributesBuilder.Append(TAG_STYLE,
						StringHelper.Format("width:%1$s;",this.getWidth()));
				}
			}else{
				attributesBuilder.Set(TAG_WIDTH,strWidth);
			}
		}
		
		if(!StringHelper.IsNullOrEmpty(this.getHeight()))
			attributesBuilder.Set(TAG_HEIGHT,this.getHeight());
	}
	
	/*
	* 判断是否存在指定键值
	 * @param strKey
	 * @return
	 */
	public boolean IsContainsKey(String strKey)
	{
		strKey = strKey.toUpperCase();
		if (extAttrList != null)
		{
			return extAttrList.containsKey(strKey);
		}
		return false;
	}

	/**
	 * @param strKey
	 * @param strDefault
	 * @return
	 */
	public String GetExtValue(String strKey, String strDefault)
	{
		strKey = strKey.toUpperCase();
		if (extAttrList != null)
			if (extAttrList.containsKey(strKey))
			{
				if(!StringHelper.IsNullOrEmpty((String) extAttrList.get(strKey))) return (String) extAttrList.get(strKey);
			}
		return strDefault;
	}

	/**
	 * @param strKey
	 * @param nDefault
	 * @return
	 */
	public int GetExtValue(String strKey, int nDefault)
	{
		try
		{
			Integer tempValue = new Integer(nDefault);
			return Integer.parseInt(GetExtValue(strKey, tempValue.toString()));
		}
		catch (Exception ex)
		{
			return nDefault;
		}
	}

	/**
	 * @param strKey
	 * @param nDefault
	 * @return
	 */
	public long GetExtValue(String strKey, long nDefault)
	{
		try
		{
			Long nTempValue = new Long(nDefault);
			return Long.parseLong(GetExtValue(strKey, nTempValue.toString()));
		}
		catch (Exception ex)
		{
			return nDefault;
		}

	}

	/**
	 * @param strKey
	 * @param bDefault
	 * @return
	 */
	public boolean GetExtValue(String strKey, boolean bDefault)
	{
		try
		{
			return Boolean.parseBoolean(GetExtValue(strKey, bDefault ? "True" : "False"));
		}
		catch (Exception ex)
		{
			return bDefault;
		}
	}

	/**
	 * 设置附加属性
	 * 
	 * @param strKey
	 * @param strValue
	 */
	public void SetExtValue(String strKey, String strValue)
	{
		if (extAttrList == null)
			extAttrList = new Hashtable();
		extAttrList.put(strKey.toUpperCase(), strValue);
	}

	/**
	 * 删除扩展属性
	 * @param strKey
	 */
	public void RemoveExtValue(String strKey)
	{
		if (extAttrList == null)
			return ;
		
		extAttrList.remove(strKey.toUpperCase());
	}
	
	/**
	 * 加载配置
	 * @param strXML
	 * @param xmlConfig
	 * @return
	 */
	public static boolean LoadFromXML(String strXML, FormItem formItem)
	{
		try
		{
			if(!StringHelper.IsNullOrEmpty(strXML)){
//				InputSource is = new InputSource(new java.io.StringReader(strXML));
//				DOMParser parser = new DOMParser();
//				parser.parse(is);
//				Document doc = parser.getDocument();
//				return formItem.LoadConfig(XmlNode.getInsance(doc.getDocumentElement()));
				Parser parser = Utils.getParserInstance();
				parser.setInputHTML(strXML);
				NodeIterator nodeIterator = parser.elements();
	            if( nodeIterator.hasMoreNodes()) {
	                Node node = nodeIterator.nextNode();
	                BasePage  tempPage = null;
	                if(formItem.getBaseTag() != null)
	                	tempPage = formItem.getBaseTag().getPage();
	                formItem.LoadConfig(XmlNode.getInsance(node,tempPage));
	            }
			}
			
			return false ;
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
			return false;
		}
	}
	
	public boolean LoadConfig(XmlNode xmlNode)
	{
		// 枚举节点自身属性
		if (true)
		{
			strNodeName = xmlNode.getNodeName();
			strNodeValue = xmlNode.getNodeValue();
			if (strNodeValue == null)
				strNodeValue = "";
		}

		// 枚举所有的属性
//		if (true)
//		{
//			NamedNodeMap attrs = xmlNode.getAttributes();
//			if (attrs != null)
//			{
//				for (int i = 0; i < attrs.getLength(); i++)
//				{
//					Node attrNode = attrs.item(i);
//					if (attrNode != null)
//						OnSetProperty(attrNode.getNodeName(), attrNode.getNodeValue());
//				}
//			}
//		}
		
		if (true)
		{
			Hashtable attrs = xmlNode.getAttributes();
			if (attrs != null)
			{
				for (Iterator it = attrs.keySet().iterator();it.hasNext();){
            		String key = String.valueOf(it.next());
					if (key != null && !key.equalsIgnoreCase("$<TAGNAME>$"))
						OnSetProperty(key, StringHelper.getValue(attrs.get(key)));
				}
			}
		}
		
		// 枚举所有的子结点
		if (true)
		{
			NodeList nodes = xmlNode.getChildNodes();
			if (nodes != null)
			{
				for (int i = 0; i < nodes.size(); i++)
				{
					XmlNode childNode = nodes.getNode(i);
					if (childNode != null)
					{
						String strNodeName = childNode.getNodeName().toUpperCase();
						
						if (StringHelper.Compare(strNodeName, "#TEXT", true) == 0)
						{
							strNodeValue += childNode.getNodeValue();
							continue;
						}

						if (StringHelper.Compare(strNodeName, "#CDATA-SECTION", true) == 0)
						{
							strNodeValue += childNode.getNodeValue();
							continue;
						}

						if (strNodeName.indexOf("#") == 0)
						{
							continue;
						}
						
						OnLoadNode(strNodeName, childNode);
					}
				}
			}

		}

		return true;
	
	}
	
	/**
	 * 加载XML节点
	 * @param strName
	 * @param xmlNode
	 */
	protected void OnLoadNode(String strName, XmlNode xmlNode)
	{
		if(this.items == null)
			this.items = new ArrayList<FormItem>();
		
		if(Button.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//工具栏
			Button button = new Button();
			button.InitTag(this.getBaseTag());
			button.init();
			button.setParentItem(this);
			button.setCss("toobar-button");
			
			button.LoadConfig(xmlNode);
			if(StringHelper.IsNullOrEmpty(button.getValue()))
				button.setValue(StringHelper.getValue(button.getNodeValue()));
			
			this.items.add(button);
		}else if(Separate.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//分隔线
			Separate sep = new Separate();
			sep.InitTag(this.getBaseTag());
			sep.LoadConfig(xmlNode);
			sep.init();
			sep.setParentItem(this);
			this.items.add(sep);
		}else if(Input.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//input 开头控件
			Input input = new Input();
			input.InitTag(this.getBaseTag());
			input.LoadConfig(xmlNode);
			input.init();
			input.setParentItem(this);
			this.items.add(input);
		}else if(Group.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//group 控件
			Group group = new Group();
			group.InitTag(this.getBaseTag());
			group.LoadConfig(xmlNode);
			group.init();
			group.setParentItem(this);
			this.items.add(group);
		}else if(Fieldset.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//group 控件
			Fieldset fieldset = new Fieldset();
			fieldset.InitTag(this.getBaseTag());
			fieldset.LoadConfig(xmlNode);
			fieldset.init();
			fieldset.setParentItem(this);
			this.items.add(fieldset);
		}else if(Table.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//表
			Table table = new Table();
			table.InitTag(this.getBaseTag());
			table.LoadConfig(xmlNode);
			table.init();
			table.setParentItem(this);
			this.items.add(table);
		}else if(Thead.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//表头
			Thead head = new Thead();
			head.InitTag(this.getBaseTag());
			head.LoadConfig(xmlNode);
			head.init();
			head.setParentItem(this);
			if(this instanceof Table){
				((Table)this).setThead(head);
			}
			this.items.add(head);
		}else if(Tbody.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//表身
			Tbody body = new Tbody();
			body.InitTag(this.getBaseTag());
			body.LoadConfig(xmlNode);
			body.init();
			body.setParentItem(this);
			if(this instanceof Table){
				((Table)this).setTbody(body);
			}
			this.items.add(body);
		}else if(Tfoot.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//表尾
			Tfoot foot = new Tfoot();
			foot.InitTag(this.getBaseTag());
			foot.LoadConfig(xmlNode);
			foot.init();
			foot.setParentItem(this);
			if(this instanceof Table){
				((Table)this).setTfoot(foot);
			}
			this.items.add(foot);
		}else if(Tr.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//行
			Tr tr = new Tr();
			tr.InitTag(this.getBaseTag());
			tr.LoadConfig(xmlNode);
			tr.init();
			tr.setParentItem(this);
			this.items.add(tr);
		}else if(Th.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//单元格 th
			Th th = new Th();
			th.InitTag(this.getBaseTag());
			th.LoadConfig(xmlNode);
			th.init();
			th.setParentItem(this);
			this.items.add(th);
		}else if(Td.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//单元格 td
			Td td = new Td();
			td.InitTag(this.getBaseTag());
			td.LoadConfig(xmlNode);
			td.init();
			td.setParentItem(this);
			this.items.add(td);
		}else if(Select.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//下拦选框
			Select select = new Select();
			select.InitTag(this.getBaseTag());
			select.LoadConfig(xmlNode);
			select.init();
			select.setParentItem(this);
			this.items.add(select);
		}else if(Option.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//下拦选框中的选项
			Option option = new Option();
			option.InitTag(this.getBaseTag());
			option.LoadConfig(xmlNode);
			option.init();
			option.setParentItem(this);
			this.items.add(option);
		}else if(Textarea.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//文本框
			Textarea textarea = new Textarea();
			textarea.InitTag(this.getBaseTag());;
			textarea.LoadConfig(xmlNode);
			textarea.init();
			textarea.setParentItem(this);
			this.items.add(textarea);
		}else if(FieldItem.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//自定义的filed栏位
			FieldItem filed = new FieldItem();
			filed.InitTag(this.getBaseTag());
			filed.LoadConfig(xmlNode);
			filed.init();
			filed.setParentItem(this);
			this.items.add(filed);
		}else if(Br.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//自定义的filed栏位
			Br br = new Br();
			br.InitTag(this.getBaseTag());
			br.init();
			this.items.add(br);
		}else if(Script.TAG_ITEMNAME.equalsIgnoreCase(strName)){
			//自定义的filed栏位
			Script script = new Script();
			script.setNodeValue(xmlNode.getNodeValue());
			this.getScript().add(script);
		}else{
			//默认控件
			FormItem item = new FormItem();
			item.InitTag(this.getBaseTag());
			item.LoadConfig(xmlNode);
			item.init();
			item.setParentItem(this);
			this.items.add(item);
		}
	}
	
	public List<FormItem> getItems() {
		if(this.items == null)
			this.items = new ArrayList<FormItem>();
		return items;
	}
	
	public void addItem(FormItem item){
		if(this.items == null)
			this.items = new ArrayList<FormItem>();
		this.items.add(item);
	}
	
	public List<Script> getScript() {
		if(this.script == null)
			this.script = new ArrayList<Script>();
		return script;
	}
	
	public String getCss() {
		return this.strCss;
	}

	public String getId() {
		if(this.getBaseTag() != null && StringHelper.IsNullOrEmpty(this.strId) && !StringHelper.IsNullOrEmpty(this.getName())){
			int itemSize = 0 ;
			if(!this.isFromTag()){ 
				itemSize = this.getBaseTag().getPage().getItemSize(this.getName());
			}else{
				itemSize = this.getBaseTag().getPage().getTagItemSize(this.getName());
			}
			
			this.setId(
					StringHelper.Format("%1$s%2$s",
							this.getName(),
							itemSize > 1 ? "_"+String.valueOf(itemSize) : "")
							);
		}
		return this.strId;
	}

	public String getName() {
		if(StringHelper.IsNullOrEmpty(this.strName))
			return this.strId;
		else
			return this.strName;
	}

	public String getStyle() {
		return this.strStyle;
	}

	public void setId(String strId) {
		this.strId = strId;
	}

	public void setName(String strName) {
		this.strName = strName;
	}

	public void setNodeName(String strNodeName) {
		this.strNodeName = strNodeName;
	}

	public void setStyle(String strStyle) {
		this.strStyle = strStyle;
	}

	public String getNodeName() {
		return strNodeName;
	}

	public void setCss(String strCss) {
		this.strCss = strCss;
	}

	public String getWidth() {
		return strWidth;
	}

	public void setWidth(String strWidth) {
		this.strWidth = strWidth;
	}

	public String getHeight() {
		return strHeight;
	}

	public void setHeight(String strHeight) {
		this.strHeight = strHeight;
	}

	public String getNodeValue() {
		return strNodeValue;
	}

	public void setNodeValue(String strNodeValue) {
		this.strNodeValue = strNodeValue;
	}
	
	public int getPos() {
		return iPos;
	}

	public void setPos(int pos) {
		iPos = pos;
	}
	
	public int getCurrentIndex() {
		return this.currentIndex;
	}
	
	public void setCurrentIndex(int index) {
		this.currentIndex = index;
	}
	
	public int getIndex() {
		return iIndex;
	}

	public void setIndex(int iIndex) {
		this.iIndex = iIndex;
	}
	
	public FormItem getParentItem() {
		return parentItem;
	}

	public void setParentItem(FormItem parentItem) {
		this.parentItem = parentItem;
	}
	
	public boolean isFromTag() {
		return bFromTag;
	}

	public void setFromTag(boolean bFromTag) {
		this.bFromTag = bFromTag;
	}
	
	public FormItem() {
		
	}
	
	public void InitTag(BaseTag tag){
		this.baseTag = tag ;
	}
	
	public BaseTag getBaseTag(){
		return this.baseTag;
	}

	public boolean isEnab() {
		return enab;
	}

	public void setEnab(boolean enab) {
		this.enab = enab;
	}

	public Hashtable getExtAttrList() {
		return extAttrList;
	}
}
